﻿namespace BankSystem
{
    public class CreditAccount : Account
    {
        public CreditAccount(string id, decimal money, string pwd, int credit) : base(id, money, pwd)
        {
            Credit = credit;
        }

        
        public int Credit { get; set; }

        private bool AddCredit(int credit)
        {
            if(credit > 0)
            {
                Credit += credit;
                return true;
            }

            return false;
        }

        public override bool WithdrawMoney(decimal money)
        {
            if (base.WithdrawMoney(money))
            {
                AddCredit((int)money);
                return true;
            }
            return false;
        }
    }
}
